#ifndef QUATERNION_H
#define QUATERNION_H

#include "common.h"
#include "vector3d.h"

typedef struct {
    double w, x, y, z;
} Quaternion;

// 四元数基本操作
Quaternion quaternion_create(double w, double x, double y, double z);
Quaternion quaternion_identity();
Quaternion quaternion_from_axis_angle(Vector3D axis, double angle);
Quaternion quaternion_from_euler(double roll, double pitch, double yaw);
Quaternion quaternion_multiply(Quaternion q1, Quaternion q2);
Quaternion quaternion_conjugate(Quaternion q);
Quaternion quaternion_inverse(Quaternion q);
double quaternion_magnitude(Quaternion q);
Quaternion quaternion_normalize(Quaternion q);
Vector3D quaternion_rotate_vector(Quaternion q, Vector3D v);

// 插值
Quaternion quaternion_slerp(Quaternion q1, Quaternion q2, double t);

// 姿态计算
Quaternion quaternion_from_to_rotation(Vector3D from, Vector3D to);
Vector3D quaternion_to_euler(Quaternion q);
double quaternion_angle(Quaternion q1, Quaternion q2);

// 打印
void quaternion_print(const char* name, Quaternion q);

#endif // QUATERNION_H
